package main

import (
	"fmt"
	"strings"
)

func findRepeatedDnaSequences(s string) []string {
	if len(s) <= 10 {
		return nil
	}
	m := make(map[string]struct{})
	for i := range s {
		if i+10 == len(s) {
			break
		}
		sub := s[i : i+10]
		if _, ok := m[sub]; ok {
			continue
		}
		if strings.Index(s[i+1:], sub) >= 0 {
			m[sub] = struct{}{}
		}
	}
	var result []string
	for k := range m {
		result = append(result, k)
	}
	return result
}

func main() {
	//ret := findRepeatedDnaSequences("AAAAACCCCCAAAAACCCCCCAAAAAGGGTTT")
	//fmt.Printf("%#v\n", ret)
	ret := findRepeatedDnaSequences("AAAAAAAAAAAAA")
	fmt.Printf("%#v\n", ret)
}
